<template>
  <div class="page-header" :class="{'inner-padding':padding}">
    <div class="wrapper">
      <el-space :size="4" class="page-title">
        <el-icon :size="20" color="#409EFF">
          <Guide/>
        </el-icon>
        <h4>{{ $route.meta.title }}</h4>
      </el-space>
      <!-- #default -->
      <slot></slot>
    </div>
    <div class="action">
      <!-- 页面操作 #action -->
      <slot name="action">
        <el-button v-if="$attrs.onCreate" :icon="Plus" type="primary" @click="$attrs.onCreate">新增</el-button>
      </slot>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { Guide, Plus } from '@element-plus/icons-vue'

defineProps<{ padding?: boolean }>()
</script>

<style lang="less" scoped>
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  :deep(.page-title + div) {
    margin-top: 30px;
  }
  .wrapper {
    flex: 1;
  }
  &.inner-padding {
    padding: 16px;
  }
}
</style>
